<div class="content-wrapper">
    <?php
    $form = $this->form;
    $form->prepare();

    $form->get('currencyName')->setAttributes([
        'placeholder' => $this->translate('货币名称')
    ]);
    $form->get('currencyRate')->setAttributes([
        'placeholder' => $this->translate('货币汇率')
    ]);
    ?>
    <?php echo $this->form()->openTag($form); ?>
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right" id="dbshop-menu-top">
            <a href="<?php echo $this->url('currency');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回货币列表'); ?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?php echo $this->translate('保存货币信息'); ?></button>
            <?php echo (isset($this->currency) ? $this->HelpUrl('currencyEdit') : $this->HelpUrl('currencyAdd')); ?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo ((isset($this->currency) && $this->currency->getCurrencyId()) ? $this->translate('编辑货币') : $this->translate('添加货币')); ?></h3>
                    </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('选择货币'); ?><span class="must_add_value">*</span></label>
                                <div class="col-sm-3">
                                    <?php echo $this->formElement($form->get('currencyCode')); ?>
                                    <?php echo $this->formElementErrors($form->get('currencyCode'), ['class'=>'error-message']); ?>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('货币名称'); ?><span class="must_add_value">*</span></label>
                                <div class="col-sm-3">
                                    <?php echo $this->formElement($form->get('currencyName')); ?>
                                    <?php echo $this->formElementErrors($form->get('currencyName'), ['class'=>'error-message']); ?>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('货币汇率'); ?><span class="must_add_value">*</span></label>
                                <div class="col-sm-3">
                                    <?php echo $this->formElement($form->get('currencyRate')); ?>
                                    <?php echo $this->formElementErrors($form->get('currencyRate'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('货币类型'); ?></label>
                                <div class="col-sm-3">
                                    <p class="form-control-static">
                                        <?php echo (isset($this->currency) && $this->currency->getCurrencyType() == 1) ? $this->translate('基础货币') : $this->translate('非基础货币'); ?>
                                    </p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('货币状态'); ?></label>
                                <div class="col-sm-1">
                                    <?php echo $this->formElement($form->get('currencyState')); ?>
                                    <?php echo $this->formElementErrors($form->get('currencyState'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                        </div>
                </div>
            </div>
        </div>

    </section>
    <?php echo $this->form()->closeTag(); ?>
</div>
<script>
    $(document).ready(function() {
        $("#<?php echo $form->getName(); ?>").validate({
            rules: {
                currencyCode: {
                    required: true
                },
                currencyRate: {
                    required: true
                }
            },
            messages: {
                currencyCode: {
                    required: "<?php echo $this->translate('请选择货币'); ?>"
                },
                currencyRate: {
                    required: "<?php echo $this->translate('汇率不能为空'); ?>"
                }
            }
        });
    });

    $('.select2').select2();
</script>